<%= content_for :javascript do %>
  <script src="/javascripts/showdown.js"></script>
  <script src="/javascripts/app/content.js"></script>
  <script type="text/javascript">
    $(document).ready(function () {
      
      <% if @has_active_categories %>
          
        $(".nav-list a").click(function (e) {
          e.preventDefault();
          $(".nav-list li").removeClass("active");
          $(this).parent().addClass("active");
          var categoryId = $(this).attr("data-id");
          App.ContentController.reload({"category": categoryId});
        })

        App.ContentController = new ContentController({"category": <%= @active_category_id %>});
      
      <% end %>           
    });
  </script>
<% end %>    
<div class="page-header">
  <h1>Frente Parlamentario</h1>
</div>
<div class="row">
  <div class="span3">        
    <% if @has_active_categories %>
      <div class="well" style="padding: 8px 0;">
        <ul class="nav nav-list">
          <% @categories.each do |category| %>            
              <li class="<%=  @active_category_id == category.id ? 'active' : ''%> <%= category.category_type == 'title' || category.category_type == 'standard-link' ? 'nav-header' : '' %>">
                <% if category.category_type == 'standard' || category.category_type == 'standard-link' %>
                  <a href="#" data-id="<%= category.id %>"><%= category.name %></a>
                <% else %>
                  <%= category.name %>
                <% end %>
              </li>
              <li class="divider"></li>            
          <% end %>
        </ul>      
      </div>
    <% end %>
  </div>
  <div class="span9" id="content-container">    
  </div>
  <div class="span9" id="section-container">
  </div>
  <div class="documents-pagination pagination pagination-centered">    
  </div>
</div>
<%= content_for :templates do %>
  <% if @has_active_categories %>
    <script id="content-template" type="text/x-handlebars-template">
      <section id="{{category}}" style="padding-top: 0px;">
        <h3 style="margin-top: 0px">
          <span>{{title}}</span>
          <div class="pull-right">
            <% if @current_account.admin? %>
              <a href="#" class="btn btn-primary btn-small show-editor" onclick="App.ContentController.showEditor();">Editar texto</a>
              <a href="#" class="btn btn-primary btn-small save-editor" onclick="App.ContentController.saveEditor();" style="display:none;">Grabar Cambios</a>
              <a href="#" class="btn btn-warning btn-small cancel-editor" onclick="App.ContentController.cancelEditor();" style="display:none;">Cancelar</a>
            <% end %>
          </div>          
        </h3>
        <div class="content-body clearfix">
          {{{body}}}
        </div>
      </section>
    </script>
  <% end %>
<% end %>
